package Demo01_15;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by 14229 on 2020/1/16.
 */
public class Test05 {
    public static void main(String[] args) {

        Random random = new Random();
        int i = random.nextInt(9999)+1;
        System.out.println("生成的随机数是："+i);
        List<Integer> list = new ArrayList<>();
        list.add(i);
        for (Integer integer : list) {
            char[] chars = integer.toString().toCharArray();
            StringBuilder sb = new StringBuilder();
            if (chars.length==1){
                sb.append("000"+i);
            }else if (chars.length==2){
                sb.append("00"+i);
            }if (chars.length==3){
                sb.append("0"+i);
            }if (chars.length==4){
                sb.append(i);
            }
            System.out.println("改变格式后："+sb);
        }

    }
}
